﻿<UserControl
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:p="clr-namespace:MyAnimelistRecommender.Properties"
             xmlns:Microsoft_Windows_Themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero"
    x:Class="MyAnimelistRecommender.Controls.TabControls.Configuration"
             mc:Ignorable="d"
             d:DesignHeight="338" d:DesignWidth="575">

    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/Resource/Style.xaml" />
                <ResourceDictionary Source="/Resource/Brush.xaml" />
                <ResourceDictionary Source="/Resource/Converter.xaml" />
            </ResourceDictionary.MergedDictionaries>
            <ControlTemplate x:Key="TabsLeftTabControlTemplate" TargetType="{x:Type TabControl}">
                <Grid ClipToBounds="True" SnapsToDevicePixels="True" KeyboardNavigation.TabNavigation="Local">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition x:Name="ColumnDefinition0"/>
                        <ColumnDefinition x:Name="ColumnDefinition1" Width="0"/>
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition x:Name="RowDefinition0" Height="Auto"/>
                        <RowDefinition x:Name="RowDefinition1" Height="*"/>
                    </Grid.RowDefinitions>
                    <Border x:Name="HeaderBorder" Grid.Column="0" Grid.Row="0" Background="White" BorderBrush="Black" BorderThickness="1">
                        <TabPanel x:Name="HeaderPanel" IsItemsHost="True" Margin="2,2,2,0" KeyboardNavigation.TabIndex="1" Panel.ZIndex="1" />
                    </Border>
                    <Border x:Name="ContentPanel" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Grid.Column="0" KeyboardNavigation.DirectionalNavigation="Contained" Grid.Row="1" KeyboardNavigation.TabIndex="2" KeyboardNavigation.TabNavigation="Local">
                        <ContentPresenter Grid.Row="1" x:Name="PART_SelectedContentHost" ContentTemplate="{TemplateBinding SelectedContentTemplate}" Content="{TemplateBinding SelectedContent}" ContentStringFormat="{TemplateBinding SelectedContentStringFormat}" ContentSource="SelectedContent" Margin="{TemplateBinding Padding}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                    </Border>
                </Grid>
                <ControlTemplate.Triggers>
                    <Trigger Property="TabStripPlacement" Value="Bottom">
                        <Setter Property="Grid.Row" TargetName="HeaderBorder" Value="1"/>
                        <Setter Property="Grid.Row" TargetName="ContentPanel" Value="0"/>
                        <Setter Property="Height" TargetName="RowDefinition0" Value="*"/>
                        <Setter Property="Height" TargetName="RowDefinition1" Value="Auto"/>
                        <Setter Property="Margin" TargetName="HeaderPanel" Value="2,0,2,2"/>
                    </Trigger>
                    <Trigger Property="TabStripPlacement" Value="Left">
                        <Setter Property="Grid.Row" TargetName="HeaderBorder" Value="0"/>
                        <Setter Property="Grid.Row" TargetName="ContentPanel" Value="0"/>
                        <Setter Property="Grid.Column" TargetName="HeaderPanel" Value="0"/>
                        <Setter Property="Grid.Column" TargetName="ContentPanel" Value="1"/>
                        <Setter Property="Width" TargetName="ColumnDefinition0" Value="Auto"/>
                        <Setter Property="MinWidth" TargetName="ColumnDefinition0" Value="100"/>
                        <Setter Property="Width" TargetName="ColumnDefinition1" Value="*"/>
                        <Setter Property="Height" TargetName="RowDefinition0" Value="*"/>
                        <Setter Property="Height" TargetName="RowDefinition1" Value="0"/>
                        <Setter Property="Margin" TargetName="HeaderPanel" Value="2"/>
                    </Trigger>
                    <Trigger Property="TabStripPlacement" Value="Right">
                        <Setter Property="Grid.Row" TargetName="HeaderBorder" Value="0"/>
                        <Setter Property="Grid.Row" TargetName="ContentPanel" Value="0"/>
                        <Setter Property="Grid.Column" TargetName="HeaderPanel" Value="1"/>
                        <Setter Property="Grid.Column" TargetName="ContentPanel" Value="0"/>
                        <Setter Property="Width" TargetName="ColumnDefinition0" Value="*"/>
                        <Setter Property="Width" TargetName="ColumnDefinition1" Value="Auto"/>
                        <Setter Property="Height" TargetName="RowDefinition0" Value="*"/>
                        <Setter Property="Height" TargetName="RowDefinition1" Value="0"/>
                        <Setter Property="Margin" TargetName="HeaderPanel" Value="0,2,2,2"/>
                    </Trigger>
                    <Trigger Property="IsEnabled" Value="False">
                        <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
                    </Trigger>
                </ControlTemplate.Triggers>
            </ControlTemplate>
            <Style x:Key="ConfigurationTabItemStyle" TargetType="{x:Type TabItem}">
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type TabItem}">
                            <Grid Margin="2 1">
                                <Border x:Name="hoverborder" BorderThickness="1" CornerRadius="3" Margin="0">
                                    <Border x:Name="bordoor" Padding="0" BorderThickness="1" CornerRadius="3">
                                        <TextBlock x:Name="Header" Text="{Binding Header, RelativeSource={RelativeSource TemplatedParent}}" FontFamily="{TemplateBinding FontFamily}"
        								Foreground="{TemplateBinding Foreground}" Padding="{TemplateBinding Padding}" >
        								<TextBlock.Effect>
        									<DropShadowEffect ShadowDepth="2" Opacity=".2" BlurRadius="10" Direction="-90" />
        								</TextBlock.Effect>
                                        </TextBlock>
                                    </Border>
                                </Border>
                            </Grid>
                            <ControlTemplate.Triggers>
                                <Trigger Property="IsSelected" Value="True">
                                    <Setter Property="Background" TargetName="bordoor" >
                                        <Setter.Value>
                                            <RadialGradientBrush Center="0 0" RadiusX="20" RadiusY="1">
                                                <GradientStop Color="#ffffff" Offset="0"/>
                                                <GradientStop Color="#ffffff" Offset="1"/>
                                            </RadialGradientBrush>
                                        </Setter.Value>
                                    </Setter>
                                    <Setter Property="BorderBrush" Value="#888" TargetName="hoverborder" />
                                    <!--<Setter Property="Opacity" Value="0.1" TargetName="shaydoo" />-->
                                </Trigger>
                                <Trigger Property="IsMouseOver" Value="True">
                                    <Setter Property="Background" TargetName="hoverborder" >
                                        <Setter.Value>
                                            <RadialGradientBrush Center="0 0" RadiusX="20" RadiusY="1">
                                                <GradientStop Color="#e4e4e4" Offset="0"/>
                                                <GradientStop Color="#ffffff" Offset="1"/>
                                            </RadialGradientBrush>
                                        </Setter.Value>
                                    </Setter>
                                    <Setter Property="BorderBrush" Value="#bbb" TargetName="hoverborder" />
                                </Trigger>
                                <Trigger Property="IsEnabled" Value="False">
                                    <Setter Property="Foreground" Value="{x:Static SystemColors.GrayTextBrush}" />
                                </Trigger>
                            </ControlTemplate.Triggers>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>

            <ControlTemplate x:Key="HeaderTextBlockTemplate" TargetType="{x:Type HeaderedContentControl}">
                <Border Background="{x:Static SystemColors.HighlightBrush}" BorderThickness="1" CornerRadius="2"
                    HorizontalAlignment="Stretch" VerticalAlignment="Top" Margin="0,5" BorderBrush="{x:Static SystemColors.HighlightTextBrush}" Height="24">
                    <Border.Effect>
                        <DropShadowEffect BlurRadius="2" Opacity="0.75" ShadowDepth="0" />
                    </Border.Effect>
                    <Grid VerticalAlignment="Top">
                        <ContentPresenter ContentSource="Header" Margin="5,0" TextOptions.TextFormattingMode="Display"
                                       TextBlock.FontSize="16" TextBlock.Foreground="{x:Static SystemColors.HighlightTextBrush}">
                            <ContentPresenter.Effect>
                                <DropShadowEffect Color="#F000" Opacity="0.75" ShadowDepth="0" />
                            </ContentPresenter.Effect>
                        </ContentPresenter>
                    </Grid>
                </Border>
            </ControlTemplate>
            <RoutedUICommand x:Key="CancelCommand" Text="Cancel" />
            <RoutedUICommand x:Key="ApplyCommand" Text="Apply" />
            <RoutedUICommand x:Key="ResetCommand" Text="Reset" />
        </ResourceDictionary>
    </UserControl.Resources>

    <UserControl.CommandBindings>
        <CommandBinding Command="{StaticResource CancelCommand}" Executed="CancelCommand_Executed" CanExecute="CancelCommand_CanExecute" />
        <CommandBinding Command="{StaticResource ApplyCommand}" Executed="ApplyCommand_Executed" CanExecute="ApplyCommand_CanExecute" />
        <CommandBinding Command="{StaticResource ResetCommand}" Executed="ResetCommand_Executed" CanExecute="ResetCommand_CanExecute" />
    </UserControl.CommandBindings>
    <Grid DataContext="{Binding Source={x:Static p:Configuration.Default}}">
        <Grid.RowDefinitions>
            <RowDefinition />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <TabControl TabStripPlacement="Left" Template="{DynamicResource TabsLeftTabControlTemplate}" >
            <TabItem Header="General" Style="{DynamicResource ConfigurationTabItemStyle}" >
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition />
                    </Grid.RowDefinitions>
                    <HeaderedContentControl Header="{Binding Header, RelativeSource={RelativeSource AncestorType={x:Type TabItem}, Mode=FindAncestor}}" Template="{StaticResource HeaderTextBlockTemplate}" />
                    <Grid Grid.Row="1">
                        <WrapPanel Grid.IsSharedSizeScope="True">
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="auto" MinWidth="60" SharedSizeGroup="confLeftCol" />
                                    <ColumnDefinition Width="auto" MinWidth="5"/>
                                    <ColumnDefinition Width="auto" MinWidth="90" SharedSizeGroup="confRightCol" />
                                </Grid.ColumnDefinitions>
                                <TextBlock VerticalAlignment="Center" Text="MyAnimeListUsername" />
                                <TextBox Grid.Column="2" Margin="2" Padding="0" Text="{Binding MyAnimeListUsername, UpdateSourceTrigger=PropertyChanged}" />
                            </Grid>
                        </WrapPanel>
                    </Grid>
                </Grid>
            </TabItem>
            <TabItem Header="wAnime" Style="{DynamicResource ConfigurationTabItemStyle}" >
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition />
                    </Grid.RowDefinitions>
                    <HeaderedContentControl Header="{Binding Header, RelativeSource={RelativeSource AncestorType={x:Type TabItem}, Mode=FindAncestor}}" Template="{StaticResource HeaderTextBlockTemplate}" />
                    <ItemsControl Grid.Row="1" Grid.IsSharedSizeScope="True">
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto" SharedSizeGroup="wAnimeCol1" />
                                <ColumnDefinition />
                            </Grid.ColumnDefinitions>
                            <TextBlock VerticalAlignment="Center" Text="Gesehene Animes: " HorizontalAlignment="Right" />

                            <Button HorizontalContentAlignment="Stretch" Grid.Column="1" Name="btnChooseSeenFolder" Style="{StaticResource CoolOpenFolderTemplate}" Padding="10 2 2 2" Click="btnChooseSeenFolder_Click">
                                <Button.Content>
                                    <Grid>
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="Auto"/>
                                            <ColumnDefinition />
                                        </Grid.ColumnDefinitions>
                                        <TextBlock VerticalAlignment="Center" Text="Pfad: " />
                                        <TextBox Grid.Column="1" HorizontalAlignment="Stretch" Text="{Binding SeenDirectory, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
                                    </Grid>
                                </Button.Content>
                            </Button>
                        </Grid>
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto" SharedSizeGroup="wAnimeCol1" />
                                <ColumnDefinition />
                            </Grid.ColumnDefinitions>
                            <TextBlock VerticalAlignment="Center" Text="Neue Animes: " HorizontalAlignment="Right" />

                            <Button HorizontalContentAlignment="Stretch" Grid.Column="1" Name="btnChooseNewAnimesDirectory" Style="{StaticResource CoolOpenFolderTemplate}" Padding="10 2 2 2" Click="btnChooseSeenFolder_Click">
                                <Button.Content>
                                    <Grid>
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="Auto"/>
                                            <ColumnDefinition />
                                        </Grid.ColumnDefinitions>
                                        <TextBlock VerticalAlignment="Center" Text="Pfad: " />
                                        <TextBox Grid.Column="1" HorizontalAlignment="Stretch" Text="{Binding ObservedDirectory, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
                                    </Grid>
                                </Button.Content>
                            </Button>
                        </Grid>
                        <CheckBox IsChecked="{Binding IsAutoRenamingEnabled, UpdateSourceTrigger=PropertyChanged}" Content="Gesehene Animes automatisch umbenennen" />
                        <CheckBox IsChecked="{Binding IsAutoGroupingEnabled, UpdateSourceTrigger=PropertyChanged}" Content="Gesehene Animes automatisch in Unterordner sortieren" />
                    </ItemsControl>
                </Grid>
            </TabItem>
            <TabItem Header="Test" Style="{DynamicResource ConfigurationTabItemStyle}" >
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition />
                    </Grid.RowDefinitions>
                    <HeaderedContentControl Header="{Binding Header, RelativeSource={RelativeSource AncestorType={x:Type TabItem}, Mode=FindAncestor}}" Template="{StaticResource HeaderTextBlockTemplate}" />
                    <Grid Grid.Row="1">
                        <StackPanel Grid.IsSharedSizeScope="True">
                            <Grid>
                                <Button Margin="10.5,17,52,-237" />
                            </Grid>
                        </StackPanel>
                    </Grid>
                </Grid>
            </TabItem>
        </TabControl>
        <StackPanel HorizontalAlignment="Right" Margin="2" Grid.Row="1" Orientation="Horizontal">
            <Button Margin="2" Content="Reset" CommandParameter="{Binding}" Command="{StaticResource ResetCommand}" />
            <Button Margin="2" Content="Cancel" CommandParameter="{Binding}" Command="{StaticResource CancelCommand}" />
            <Button Margin="2" Content="Apply" CommandParameter="{Binding}" Command="{StaticResource ApplyCommand}" />
        </StackPanel>
    </Grid>
</UserControl>